<template>
  <div class="bpl1-bg">
    <div class="co-title">
      <div class="co-title-name">
        <img src="@/assets/cockpit/subdivision/gdbh-text-ntcbq.png" alt="" />
      </div>
      <div class="co-title-right gdbh-title-right">
        <!-- <div class="co-title-select gdbh-selected">
          <el-select v-model="selectedValue" placeholder="请选择" :popper-append-to-body="false">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
          </el-select>
        </div> -->
        <div class="right-text">单位：公顷</div>
      </div>
    </div>
    <div class="detail-content">
      <div class="left">
        <div class="com-title-style">
          <div class="title-line">
            <img src="@/assets/cockpit/subdivision//wq-icon-yq.png" alt="" />
          </div>
          <div class="text-area">
            <p class="text">储备区总面积</p>
            <p class="num">2952.81</p>
          </div>
        </div>
        <ul class="mid-area">
          <li class="line"></li>
          <li class="title">其中</li>
          <li class="line"></li>
        </ul>
        <ul class="detail-num">
          <li>
            <div class="title">
              <div class="icon"></div>
              <div class="name">水田</div>
            </div>
            <div class="number">1821.23</div>
          </li>
          <li>
            <div class="title">
              <div class="icon"></div>
              <div class="name">旱地</div>
            </div>
            <div class="number">1821.23</div>
          </li>
          <li>
            <div class="title">
              <div class="icon"></div>
              <div class="name">水浇地</div>
            </div>
            <div class="number">1821.23</div>
          </li>
        </ul>
      </div>
      <div class="mid-line"></div>
      <div class="right">
        <div class="co-zb-cylindrical" id="cylindrical"></div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'
import echarts from 'echarts'

@Component({
  name: 'LandProtectionItem5',
  components: {}
})
export default class LandProtectionItem5 extends Vue {
  private selectedValue = 1
  private options = [
    {
      value: 1,
      label: '2021年'
    }
  ]
  mounted() {
    this.initCylindrical()
  }
  initCylindrical() {
    var Xdata = ['63', '27.90', '33.52', '17.98', '42.25', '24.54', '33.96', '11', '72.58']
    var Ydata = ['芙蓉区', '天心区', '开福区', '岳麓区', '雨花区', '望城区', '长沙县', '宁乡市', '浏阳市']
    const myChart = echarts.init(document.getElementById('cylindrical') as HTMLElement)
    let option = {
      // title: {
      //   text: '测试数据',
      //   textStyle: {
      //     fontSize: 12,
      //     color: '#E4765D' //标题颜色
      //   },
      //   subtext: '',
      //   subtextStyle: {
      //     fontSize: 12,
      //     color: '#E4765D' //副标题标题颜色
      //   }
      // },
      // color: ['#3398DB'],
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          // 坐标轴指示器，坐标轴触发有效
          type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
        }
      },
      grid: {
        top: '2%',
        left: '8%',
        right: '8%',
        bottom: '3%',
        containLabel: true
      },
      xAxis: {
        //坐标轴类型(类目轴)
        name: '',
        type: 'value',
        axisLabel: {
          show: false
        },

        //是否显示坐标轴刻度
        axisTick: { show: false },
        //坐标轴线线的颜色
        axisLine: {
          show: false
        },

        //是否显示网格线
        splitLine: {
          show: false
        }
      },

      dataZoom: [
        //滑动条
        {
          yAxisIndex: 0, //这里是从X轴的0刻度开始
          show: false, //是否显示滑动条，不影响使用
          type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
          startValue: 0, // 从头开始。
          endValue: 3 // 一次性展示5个。
        }
      ],
      yAxis: [
        {
          type: 'category',
          inverse: true, //是否是反向坐标轴
          data: Ydata,
          axisLabel: {
            show: true,
            width: 100,
            textStyle: {
              color: '#ffffff'
            },
            formatter: function(value: any) {
              // var value
              // if判断转换值
              return value
            }
          },
          offset: 10,
          nameTextStyle: {
            fontSize: 15
          },
          splitLine: { show: false },
          axisTick: { show: false },
          //坐标轴线线的颜色
          axisLine: {
            show: true,
            lineStyle: {
              color: '#0E3B57',
              type: 'solid',
              width: 0
            }
          }
        }
      ],
      series: [
        {
          name: '面积',
          type: 'bar',
          barMaxWidth: 10,
          data: Xdata,
          barWidth: 10,
          barGap: 10,
          smooth: true,
          showBackground: true,
          itemStyle: {
            emphasis: {
              // barBorderRadius: 7
            },
            //颜色渐变
            normal: {
              // barBorderRadius: 7,
              label: {
                show: true, //开启显示
                position: 'right', //在上方显示
                textStyle: {
                  //数值样式
                  color: '#ffffff',
                  fontSize: 12
                }
              },
              color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
                { offset: 0, color: '#00FFAA' },
                { offset: 0.5, color: '#00FFAA' },
                { offset: 1, color: '#6DFFD6' }
              ])
            }
          }
        }
      ]
    }
    //自动滚动
    this.timeOut = setInterval(() => {
      if (option.dataZoom[0].endValue === Xdata.length) {
        option.dataZoom[0].endValue = 3
        option.dataZoom[0].startValue = 0
      } else {
        option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1
        option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1
      }
      myChart.setOption(option)
    }, 1000)
  }
}
</script>
<style lang="scss" scoped>
@import '~@/styles/cockpit.scss';
.bpl1-bg {
  width: 100%;
  height: 100%;
  padding: 22px 12px 12px 16px;
  background: url('~@/assets/cockpit/bb-bg.png') no-repeat 0/ 100% 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  .co-title {
    flex-shrink: 0;
  }
  .gdbh-title-right {
    display: flex;
    .right-text {
      font-size: 12px !important;
      color: #dffeff;
      margin-top: 8px;
    }
  }
  .gdbh-selected {
    width: 101px !important;
    margin-right: 10px;
  }
}

.bpl1-table {
  width: 100%;
  .bpl1-tbe {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0px 2px;
    text-align: center;
    .bpl1-tbeh {
      height: 20px;
      background: rgba(#fff, 0.1);
      th {
        font-size: 12px !important;
        line-height: 18px;
        color: #bffeff;
        font-weight: 400;
      }
    }
    .bpl1-tbeb {
      td {
        padding: 4px 4px;
        background: rgba(#fff, 0.05);
        font-size: 16px !important;
        line-height: 20px;
        color: #fff;
        font-weight: 500;
        > span {
          font-size: 12px !important;
          color: #fff;
          font-weight: 400;
        }
      }
      .bpl1-tbeb-title {
        padding: 0 0 0 2px !important;
        background: none;
        border-left: 2px solid #006aff;
        position: relative;
        > p {
          width: 100%;
          height: 100%;
          padding: 4px;
          background: rgba(#fff, 0.05);
          line-height: 20px;
          text-align: center;
          font-size: 12px !important;
          color: #fff;
          font-weight: 400;
        }
      }
    }
  }
}

.com-title-style {
  margin-bottom: 4px;
  margin-top: 16px;
  color: #bffeff;
  display: flex;
  .text-area {
    .text {
      font-size: 12px !important;
      color: #bffeff;
    }
    .num {
      font-size: 24px !important;
      color: #fff;
    }
  }

  .title-line {
    width: 40px;
    margin-top: 0px;
    img {
      display: block;
      width: 100%;
    }
  }
}

.mid-area {
  display: flex;
  width: 100%;
  .line {
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin-top: 6px;
  }
  .title {
    flex-shrink: 0;
    font-size: 12px !important;
    color: #bffeff;
    margin: auto 4px;
  }
}

.detail-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  flex: 1;
  .left {
    flex: 1;
    .com-title-style {
      margin-bottom: 4px;
      margin-top: 16px;
      color: #bffeff;
      display: flex;

      .title-line {
        width: 40px;
        img {
          display: block;
          width: 100%;
        }
      }
    }
    .detail-num {
      margin-top: 7px;
      li {
        display: flex;
        justify-content: space-between;
        width: 210px;
        height: 24px;
        line-height: 24px;
        background: rgba(255, 255, 255, 0.05);
        margin-bottom: 6px;

        .title {
          display: flex;
          margin-left: 6px;
          .icon {
            width: 4px;
            height: 4px;
            margin-top: 10px;
            margin-right: 6px;
            display: block;
            background: #f9f0d4;
            border-radius: 1px;
            box-shadow: 0 0 4px 1px #f0b04a;
            transform: rotate(45deg);
          }
          .name {
            font-size: 12px;
            color: #bffeff;
          }
        }

        .number {
          font-size: 14px !important;
          text-align: right;
          color: #fff;
          margin-right: 6px;
        }
      }
    }
  }
  .mid-line {
    width: 1px;
    height: 160px;
    background: rgba(255, 255, 255, 0.1);
    margin-left: 8px;
    margin-top: 10px;
    margin-right: 8px;
    flex-shrink: 0;
  }
  .right {
    flex: 1;
    .co-zb-cylindrical {
      width: 100%;
      height: 150px;
      margin-top: 20px;
    }
  }
}
</style>
